#include <unistd.h>
#include<stdio.h>
#include <sys/types.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
	int fd ;
	int pipefd[2];
	if(pipe(pipefd) == -1){
		printf("init pipe fild\n");
		exit(EXIT_FAILURE);
	}
	fd = fork();
	if (fd == 0)
	{
		printf("child :%d[%d]\n",getpid(),getppid());
		close(pipefd[1]);
		char buf ;
		while(read(pipefd[0],&buf,1)>0)
			printf("%c", buf);
		printf("\n");
		while(1);
	}else{
		close(pipefd[0]);
		write(pipefd[1],"this is a massage!!!",20);
		close(pipefd[1]);
		printf("parent :%d[%d]\n",getpid() ,getppid());
		while(1);
	}
	return 0;
}